package {
	import flash.events.Event;
	import flash.display.Bitmap;
	import flash.display.Sprite;


	public class LanzasH extends Sprite {
		[Embed(source='../assets/trampa.png')]
		public var myTrampa:Class;
		private var myAura:Sprite;
		private var myParent:ScreenGame;
		private var t:uint = 0;
		
		public function LanzasH(par:ScreenGame) {
			var trap:Bitmap = new myTrampa();
			addChild(trap);
			drawAura();
			myParent = par;
			addEventListener(Event.ENTER_FRAME, onEnterFrame);
		}
		private function drawAura():void{
			myAura = new Sprite;
			myAura.graphics.beginFill(0x00ff00);
			myAura.graphics.drawRect(20, 20, 20, 160);
			addChild(myAura);
			myAura.visible = false;
		}
		
		public function get aura():Sprite{
			return myAura;
		}
		public function set aura(value:Sprite):void{
			myAura = value;
		}
		private function animateLanzaH():void{
			var period:Number = 40;
			t++;
			if (t == period) {
				t = 0;
			}
			if ( t < period/2) {
				this.x += 9;
			} else {
				this.x -= 9;
			}
		}
		private function onEnterFrame(e:Event):void{
			if (!(myParent.pause)){
				animateLanzaH(); 
			}
		}
	}
}
